<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<html>
<head>
	<title>司机管理</title>
	<meta name="decorator" content="default"/>
	<link href="${ctxStatic}/static_back/css/public.css" type="text/css" rel="stylesheet">
	<link href="${ctxStatic}/static_back/css/main.css" type="text/css" rel="stylesheet">
</head>

<body>
	<%--标题--%>
	<div class="top-section">
		<input id="btnCancel" class="back-link" type="button" value="&lt;" onclick="history.go(-1)"/>
		<h2><shiro:hasPermission name="air:airDriver:edit">${not empty airDriver.id?'修改司机信息':'新增司机'}</shiro:hasPermission></h2>
	</div>

	<%--表单主体--%>
	<div class="body-section white-body form-body" >
		<form:form id="inputForm" modelAttribute="airDriver" action="${ctx}/air/airDriver/save" method="post" >
			<form:hidden path="id"/>
			<sys:message content="${message}"/>

			<div class="form-box" style="margin-bottom: 0">
				<div class="input-div">
					<span>姓名</span>
					<div>
						<form:input path="name" htmlEscape="false" class=""/>
						<em>*</em>
					</div>
				</div>
				<div class="input-div">
					<span>身份证</span>
					<div>
						<form:input path="idNumber" htmlEscape="false" class=""/>
					</div>
				</div>
				<div class="input-div">
					<span>所属单位</span>
					<div>
						<form:input path="belongUnit" htmlEscape="false" class=""/>
					</div>
				</div>
				<div class="input-div">
					<span>联系电话</span>
					<div>
						<form:input path="phone" htmlEscape="false" class=""/>
					</div>
				</div>
				<div class="input-div">
					<span>对讲机</span>
					<div>
						<form:input path="interphone" htmlEscape="false" class=""/>
					</div>
				</div>
			</div>

			<div class="form-box form-box-gary" style="margin-right: 40%;">
				<div class="input-div">
					<span>驾驶车辆</span>
					<div>
						<form:select id="cars" path="airCar.id" onchange="javascript:changeCar();">
							<form:options items="${cars}" itemLabel="carNumber" itemValue="id"/>
						</form:select>
					</div>
				</div>
				<div class="input-div">
					<span>类型</span>
					<div>
						<form:input id="carType" disabled="true" path="airCar.type" htmlEscape="false" />
					</div>
				</div>
				<div class="input-div">
					<span>座位数</span>
					<div>
						<form:input id="carSeating" disabled="true" path="airCar.seating" htmlEscape="false" cssStyle="width: 100px;" /> 个
					</div>
				</div>
				<div class="input-div">
					<span>服务站点</span>
					<div>
						<form:input id="carRidePoint" type="hidden" path="airCar.airRidePoint.id" htmlEscape="false" />
						<form:input id="carRidePointName" disabled="true" path="airCar.airRidePoint.name" htmlEscape="false" />
					</div>
				</div>
			</div>

			<div class="form-bottom">
				<shiro:hasPermission name="air:airDriver:edit">
					<input id="btnSubmit" class="btn btn-blue" type="submit" value="保 存"/>
				</shiro:hasPermission>
			</div>
		</form:form>
	</div>

	<script type="text/javascript">
		$(document).ready(function() {
			$("#inputForm").validate({
				submitHandler: function(form){
//					loading('正在提交，请稍等...');
					form.submit();
				},
				errorContainer: "#messageBox",
				errorPlacement: function(error, element) {
					$("#messageBox").text("输入有误，请先更正。");
					if (element.is(":checkbox")||element.is(":radio")||element.parent().is(".input-append")){
						error.appendTo(element.parent().parent());
					} else {
						error.insertAfter(element);
					}
				}
			});
		});

		function changeCar(){
			var val = $("#cars").val();
			$.ajax({
				url: "${ctx}/air/airCar/getCarMessage",
				data: {carid:val},
				type: "GET",
				dataType: "json",
				success: function (car) {
					console.log("success");
					$("#carType").val(car.data.type);
					$("#carSeating").val(car.data.seating);
					$("#carRidePoint").val(car.data.airRidePoint.id);
					$("#carRidePointName").val(car.data.airRidePoint.name);
				},
				error: function (error) {
					console.log("error");
					console.log(error);
				}
			});
		}
	</script>

</body>
</html>